﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using TinyEngine.Core.Entities;
using TinyEngine.Core.Services;
using TinyEngine.Core;
using TinyEngine.Editor.Extensibility;

namespace TinyEngine.Editor.DefaultPlugins.TileEditor
{
    public partial class TileEditor : UserControl, IEntityEditor
    {
        TileGridEntity tileGrid;
        TilesetRenderer re = new TilesetRenderer();
        TileEntityRenderer ent = new TileEntityRenderer();
        public TileEditor()
        {
            InitializeComponent();
            windowsFormsHost1.Child = re;
            windowsFormsHost2.Child = ent;
            this.Loaded += new RoutedEventHandler(TileEditor_Loaded);
            
        }

        void TileEditor_Loaded(object sender, RoutedEventArgs e)
        {
            re.SetDefinition(tileGrid.AssetList.First().Value.Asset, tileGrid.TileSizeX, tileGrid.TileSizeY);
        }


        public void SetEntity(IEntity entity)
        {
            tileGrid = entity as TileGridEntity;
            ent.SetTileGrid(entity as TileGridEntity);
        }
    }
}
